home *** CD-ROM | disk | FTP | other *** search
-
- #line 3 "MainD3DShaderTemplate"
-
- //------------------------------
- //Fallback parameters start here
- //------------------------------
-
- //Diffuse color parameters
- //Final diffuse color is computed using this equation
- //DiffuseColor = VertexColor * ps11fal_VertexColorMod + ps11fal_DiffuseColor + ps11fal_DiffuseMapMod * ps11fal_DiffuseMap
- texture ps11fal_DiffuseMap : RsD3Dps11Fal_DiffuseMap;
- float4 ps11fal_DiffuseColor : RsD3Dps11Fal_DiffuseColor = float4(0.0, 0.0, 0.0, 0.0);
- float4 ps11fal_DiffuseMapMod : RsD3Dps11Fal_DiffuseMapMod = float4(0.0, 0.0, 0.0, 0.0);
- float4 ps11fal_VertexColorMod : RsD3Dps11Fal_VertexColorMod = float4(0.7, 0.7, 0.7, 1.0);
-
- texture ps11fal_NormalMap : RsD3Dps11Fal_NormalMap;
- float4 ps11fal_SpecularColor : RsD3Dps11Fal_SpecularColor = float4(1.0, 1.0, 1.0, 1.0);
- float ps11fal_Shininess : RsD3Dps11Fal_Shininess = 20.0;
- //float4 ps11fal_ : RsD3Dps11Fal_;
-
- //------------------------------
- //The default light processing
- //
- //ps11fal_LightToggle is used to toggle between directional or positional light.
- //It is actually used in LERP between real light_to_point vector and ps11fal_LightDir
- //if ps11fal_LightToggle == 1 then only ps11fal_LightDir is used.
- //
- //Light attenuation is computed as saturate(1 / (Att.x * dist^2 + Att.y * dist + Att.z))
- //Att = ps11fal_LightAtten;
- //Attenuation start is added to the equation by modification of the distance vector
- //dist = max(0, real_dist - AttenStart);
- float4 ps11fal_LightPos : RsD3Dps11Fal_LightPosition = float4(0.0, 0.0, 0.0, 1.0);
- float3 ps11fal_LightDir : RsD3Dps11Fal_LightDirection = float3(0.0, 0.0, 0.0);
- float ps11fal_LightToggle : RsD3Dps11Fal_LightToggle = 0.0;
- float4 ps11fal_LightColor : RsD3Dps11Fal_LightColor = float4(1.0, 1.0, 1.0, 1.0);
- float ps11fal_LightAttenStart : RsD3Dps11Fal_LightAttenStart = 0.0;
- float3 ps11fal_LightAtten : RsD3Dps11Fal_LightAtten = float3(0.0, 0.0, 1.0);
-
- //------------------------------
- //Texture coordinates processing
- //
- float ps11fal_TCScaleX : RsD3Dps11Fal_TCScaleX = 1.0;
- float ps11fal_TCScaleY : RsD3Dps11Fal_TCScaleY = 1.0;
- float ps11fal_TCMoveX : RsD3Dps11Fal_TCMoveX = 0.0;
- float ps11fal_TCMoveY : RsD3Dps11Fal_TCMoveY = 0.0;
-
- //------------------------------
- //PS 1.4 Specular maps
- //
- texture ps11fal_PS14SpecularMap : RsD3Dps11Fal_PS14SpecularMap;
-
- sampler ps11fal_smplDiffuse = sampler_state {
- Texture = <ps11fal_DiffuseMap>;
-
- MinFilter = LINEAR;
- MagFilter = LINEAR;
- MipFilter = LINEAR;
-
- AddressU = WRAP;
- AddressV = WRAP;
- };
-
- sampler ps11fal_smplNormal = sampler_state {
- Texture = <ps11fal_NormalMap>;
-
- MinFilter = LINEAR;
- MagFilter = LINEAR;
- MipFilter = LINEAR;
-
- AddressU = WRAP;
- AddressV = WRAP;
- };
-
- sampler ps11fal_smplSpecular = sampler_state {
- Texture = <ps11fal_PS14SpecularMap>;
-
- MinFilter = LINEAR;
- MagFilter = LINEAR;
- MipFilter = LINEAR;
-
- AddressU = CLAMP;
- AddressV = CLAMP;
- };
-
- float RsD3DComputeShininess()
- {
- return (ps11fal_Shininess<=1.0f) ? 20.0f : ps11fal_Shininess;
- }
-
- float3x3 RsD3DComputeTangentTransform(float3 vTangent, float3 vNormal, in float3x3 mToWorld) {
- float3x3 mToTangent;
- mToTangent[0] = normalize(mul(vTangent, mToWorld));
- mToTangent[2] = normalize(mul(vNormal, mToWorld));
- mToTangent[1] = cross(mToTangent[0], mToTangent[2]);
- return mToTangent;
- }
-
- float2 RsD3DComputeTexCoords(float2 vInputCoords) {
- float2 vRetVal = vInputCoords;
- vRetVal.x = vInputCoords.x * ps11fal_TCScaleX + ps11fal_TCMoveX;
- vRetVal.y = vInputCoords.y * ps11fal_TCScaleY + ps11fal_TCMoveY;
- return vRetVal;
- }
-
- //------------------------------
- // This is a fallback code for PS 2.0 hardware
- // We do per pixel diffuse and per pixel specular
- //------------------------------
- struct VS_OUTPUT_PS20 {
- float4 vClipPos : POSITION; //Clipping space position
- float2 tcCoord : TEXCOORD0; //texture coordinates
- float3 vLight : TEXCOORD1; //light vector
- float3 vEye : TEXCOORD2; //eye vector
- float4 vDistToLight : TEXCOORD3; //distance from light
- float4 cVertexColor : TEXCOORD4; //vertex color
- };
-
- VS_OUTPUT_PS20 VS_Fallback_ForPS20HW(in D3_VERTEXINPUT input)
- {
- VS_OUTPUT_PS20 output;
-
- //Following code outputs position and texture coordinates
- //------------------------------
- output.vClipPos = mul(input.D3_pInputPosition, D3_mObjectToClip); //vertex clip position
- output.tcCoord = RsD3DComputeTexCoords(input.D3_vInputTexCoords1); //Texture coordinates for color texture
-
- float4 pVertexWorld = mul(input.D3_pInputPosition, D3_mObjectToWorld); //Transform vertex into world position
- float3x3 mToTangent = RsD3DComputeTangentTransform(input.D3_vInputTangent, input.D3_vInputNormal, D3_mObjectToWorldN);
-
- //Compute light and eye vectors
- //------------------------------
- float3 vToLight = lerp(ps11fal_LightPos.xyz - pVertexWorld.xyz, -ps11fal_LightDir, ps11fal_LightToggle);
- output.vLight = mul(mToTangent, normalize(vToLight));
- float fRealDistToLight = length(vToLight);
- float fDistToLight = max(0, fRealDistToLight - ps11fal_LightAttenStart);
- output.vDistToLight = fDistToLight;
-
- float3 vToEye = normalize(D3_pEye - pVertexWorld);
- output.vEye = mul(mToTangent, vToEye);
-
- output.cVertexColor = input.D3_cInputColor * ps11fal_VertexColorMod + ps11fal_DiffuseColor;
-
- return output;
- }
-
- float4 PS_Fallback_ForPS20HW(in VS_OUTPUT_PS20 input) : COLOR0
- {
- float4 cDecal = tex2D(ps11fal_smplDiffuse, input.tcCoord);
- float3 cNormal = tex2D(ps11fal_smplNormal, input.tcCoord).xyz;
- float3 vNormal = normalize(2.0f * cNormal - 1.0f); //expand to the range -1,1
- float3 vEye = normalize(input.vEye);
- float3 vLight = normalize(input.vLight);
-
- //Compute final light color with respect to the attenuation
- //------------------------------
- float fDistToLight = input.vDistToLight.w;
- float fAttenuation = ps11fal_LightAtten.x * fDistToLight * fDistToLight + ps11fal_LightAtten.y * fDistToLight + ps11fal_LightAtten.z;
- float4 cLightColor = ps11fal_LightColor * saturate(1.0f / fAttenuation);
-
- float3 vRefVec = dot(vLight, vNormal) * 2 * vNormal - vLight;
- float fEyeDotRef = max(0, dot(vRefVec, vEye));
- float4 cSpecularCol = ps11fal_SpecularColor * pow(fEyeDotRef, RsD3DComputeShininess());
-
- float fDiffuseDot = saturate(dot(vNormal, vLight));
- float4 diffuseColor = input.cVertexColor + ps11fal_DiffuseMapMod * cDecal;
- float4 cOut = cLightColor * (cSpecularCol + diffuseColor * fDiffuseDot);
- cOut.a = diffuseColor.a;
- return cOut;
- }
-
- technique D3_FALLBACK_TECHNIQUE_PS20
- <
- string Rs_PSVersion = "PS_2_0";
- string Rs_TechniqueMode = "firstlight";
- >
- {
- pass D3_FALLBACK_PASS_02_PS20
- {
- VertexShader = compile vs_2_0 VS_Fallback_ForPS20HW();
- PixelShader = compile ps_2_0 PS_Fallback_ForPS20HW();
-
- AlphaBlendEnable = false;
-
- ZEnable = true;
- ZFunc = LESSEQUAL;
- ZWriteEnable = true;
-
- CullMode = CCW;
- }
- }
-
- technique D3_FALLBACK_TECHNIQUE_PS20_MORELIGHTS
- <
- string Rs_PSVersion = "PS_2_0";
- string Rs_TechniqueMode = "morelights";
- >
- {
- pass D3_FALLBACK_PASS_02_PS20
- {
- VertexShader = compile vs_2_0 VS_Fallback_ForPS20HW();
- PixelShader = compile ps_2_0 PS_Fallback_ForPS20HW();
-
- AlphaBlendEnable = true;
- SrcBlend = ONE;
- DestBlend = ONE;
-
- ZEnable = true;
- ZFunc = EQUAL;
- ZWriteEnable = false;
-
- CullMode = CCW;
- }
- }
-
- //------------------------------
- // This is a fallback code for PS 1.4 hardware
- // We do per pixel diffuse and per pixel specular. Attenuation is computed per vertex.
- //------------------------------
- struct VS_OUTPUT_PS14 {
- float4 vClipPos : POSITION; //Clipping space position
- float2 tcCoord : TEXCOORD0; //texture coordinates
- float3 vLight : TEXCOORD1; //light vector
- float3 vEye : TEXCOORD2; //eye vector
- float4 cLightColor : COLOR1; //light color with attenuation
- float4 cVertexColor : COLOR0; //vertex color
- };
-
- VS_OUTPUT_PS14 VS_Fallback_ForPS14HW(in D3_VERTEXINPUT input)
- {
- VS_OUTPUT_PS14 output;
-
- //Following code outputs position and texture coordinates
- //------------------------------
- output.vClipPos = mul(input.D3_pInputPosition, D3_mObjectToClip); //vertex clip position
- output.tcCoord = RsD3DComputeTexCoords(input.D3_vInputTexCoords1); //Texture coordinates for color texture
- float4 pVertexWorld = mul(input.D3_pInputPosition, D3_mObjectToWorld); //Transform vertex into world position
-
- float3x3 mToTangent = RsD3DComputeTangentTransform(input.D3_vInputTangent, input.D3_vInputNormal, D3_mObjectToWorldN);
-
- //Compute light and eye vectors
- //------------------------------
- float3 vToLight = lerp(ps11fal_LightPos.xyz - pVertexWorld.xyz, -ps11fal_LightDir, ps11fal_LightToggle);
- float fRealDistToLight = length(vToLight);
- vToLight = normalize(vToLight);
-
- float3 vToEye = normalize(D3_pEye - pVertexWorld);
-
- //Compute final light color with respect to the attenuation
- //------------------------------
- float fDistToLight = max(0, fRealDistToLight - ps11fal_LightAttenStart);
- float fAttenuation = ps11fal_LightAtten.x * fDistToLight * fDistToLight + ps11fal_LightAtten.y * fDistToLight + ps11fal_LightAtten.z;
- fAttenuation = saturate(1 / fAttenuation);
- output.cLightColor = ps11fal_LightColor * fAttenuation;
-
- //Compute final per vertex color using
- //------------------------------
- output.cVertexColor = input.D3_cInputColor * ps11fal_VertexColorMod + ps11fal_DiffuseColor;
-
- output.vLight = mul(mToTangent, vToLight);
- output.vEye = mul(mToTangent, vToEye);
-
- return output;
- }
-
- float4 PS_Fallback_ForPS14HW(in VS_OUTPUT_PS14 input) : COLOR0
- {
- float4 cDecal = tex2D(ps11fal_smplDiffuse, input.tcCoord);
- float3 cNormal = tex2D(ps11fal_smplNormal, input.tcCoord).xyz;
- float3 vNormal = 2.0f * cNormal - 1.0f;
- float3 vLight = input.vLight;
-
- float fNdotL = dot(vLight, vNormal);
- float4 diffuseColor = input.cVertexColor + ps11fal_DiffuseMapMod * cDecal;
-
- //Specular term
- float3 vEye = input.vEye;
- float3 vRefVec = 2.0f * fNdotL * vNormal - vLight;
- float2 vCoord;
- vCoord.x = dot(vEye, vRefVec);
- vCoord.y = RsD3DComputeShininess() / 100.0f;
- float4 cSpecularTerm = tex2D(ps11fal_smplSpecular, vCoord);
- float4 cSpecularCol = ps11fal_SpecularColor * cSpecularTerm.a;
-
- float4 cOut;
- cOut.rgb = input.cLightColor * (cSpecularCol + diffuseColor * saturate(fNdotL));
- cOut.a = diffuseColor.a;
- return cOut;
- }
-
- technique D3_FALLBACK_TECHNIQUE_PS14
- <
- string Rs_PSVersion = "PS_1_4";
- string Rs_TechniqueMode = "firstlight";
- >
- {
- pass D3_FALLBACK_PASS_02_PS20
- {
- VertexShader = compile vs_1_1 VS_Fallback_ForPS14HW();
- PixelShader = compile ps_1_4 PS_Fallback_ForPS14HW();
-
- AlphaBlendEnable = false;
- ZEnable = true;
- ZFunc = LESSEQUAL;
- ZWriteEnable = true;
-
- CullMode = CCW;
- }
- }
-
- technique D3_FALLBACK_TECHNIQUE_PS14_MORELIGHT
- <
- string Rs_PSVersion = "PS_1_4";
- string Rs_TechniqueMode = "morelights";
- >
- {
- pass D3_FALLBACK_PASS_02_PS20
- {
- VertexShader = compile vs_1_1 VS_Fallback_ForPS14HW();
- PixelShader = compile ps_1_4 PS_Fallback_ForPS14HW();
-
- AlphaBlendEnable = true;
- SrcBlend = ONE;
- DestBlend = ONE;
-
- ZEnable = true;
- ZFunc = EQUAL;
- ZWriteEnable = false;
-
- CullMode = CCW;
- }
- }
-
- //------------------------------
- // This is a fallback code for PS 1.1 hardware
- // We do per pixel diffuse and per vertex specular
- //------------------------------
- struct VS_OUTPUT_PS11 {
- float4 vClipPos : POSITION; //Clipping space position
- float4 cVertexColor : COLOR0; //vertex color
- float4 cLightColor : COLOR1; //light color with attenuation
- float2 tcCoord0 : TEXCOORD0;//texture coordinates
- float2 tcCoord1 : TEXCOORD1;//texture coordinates
- float3 vLight : TEXCOORD2;//light vector
- float4 cSpecularCol : TEXCOORD3;//complete specular color component
- };
-
- VS_OUTPUT_PS11 VS_Fallback_ForPS11HW(in D3_VERTEXINPUT input)
- {
- VS_OUTPUT_PS11 output;
-
- //Following code outputs position and texture coordinates
- //------------------------------
- output.vClipPos = mul(input.D3_pInputPosition, D3_mObjectToClip); //vertex clip position
- float4 pVertexWorld = mul(input.D3_pInputPosition, D3_mObjectToWorld); //Transform vertex into world position
-
- float3x3 mToTangent = RsD3DComputeTangentTransform(input.D3_vInputTangent, input.D3_vInputNormal, D3_mObjectToWorldN);
-
- //Compute light and eye vectors
- //------------------------------
- float3 vToLight = lerp(ps11fal_LightPos.xyz - pVertexWorld.xyz, -ps11fal_LightDir, ps11fal_LightToggle);
- float fRealDistToLight = length(vToLight);
- vToLight = normalize(vToLight);
-
- float3 vToEye = normalize(D3_pEye - pVertexWorld);
-
- //Compute final light color with respect to the attenuation
- //------------------------------
- float fDistToLight = max(0, fRealDistToLight - ps11fal_LightAttenStart);
- float fAttenuation = ps11fal_LightAtten.x * fDistToLight * fDistToLight + ps11fal_LightAtten.y * fDistToLight + ps11fal_LightAtten.z;
- fAttenuation = saturate(1 / fAttenuation);
- output.cLightColor = ps11fal_LightColor * fAttenuation;
-
- //Compute final per vertex color using
- //------------------------------
- float3 vRefVec = dot(vToLight, mToTangent[2]) * 2 * mToTangent[2] - vToLight;
- float fEyeDotRef = max(0, dot(vRefVec, vToEye));
-
- output.tcCoord0 = RsD3DComputeTexCoords(input.D3_vInputTexCoords1); //Texture coordinates for color texture
- output.tcCoord1 = output.tcCoord0; //Texture coordinates for normal texture
-
- output.cSpecularCol = output.cLightColor * ps11fal_SpecularColor * pow(fEyeDotRef, RsD3DComputeShininess());
- output.cVertexColor = input.D3_cInputColor * ps11fal_VertexColorMod + ps11fal_DiffuseColor;
-
- output.vLight = mul(mToTangent, vToLight);
- output.vLight = 0.5 * output.vLight + 0.5;
-
- return output;
- }
-
- float4 PS_Fallback_ForPS11HW(in VS_OUTPUT_PS11 input) : COLOR0
- {
- float4 cDecal = tex2D(ps11fal_smplDiffuse, input.tcCoord0);
- float3 cNormal = tex2D(ps11fal_smplNormal, input.tcCoord1).xyz;
- float3 vNormal = 2.0f * cNormal - 1.0f; //expand to the range -1,1
- float3 vLight = 2.0f * input.vLight - 1.0f; //expand to the range -1,1
- float fDiffuseDot = saturate(dot(vNormal, vLight));
- float4 diffuseColor = input.cVertexColor + ps11fal_DiffuseMapMod * cDecal;
- float4 cOut = input.cSpecularCol + input.cLightColor * diffuseColor * fDiffuseDot;
- cOut.a = diffuseColor.a;
- return cOut;
- }
-
- technique D3_FALLBACK_TECHNIQUE_PS11
- <
- string Rs_PSVersion = "PS_1_1";
- string Rs_TechniqueMode = "firstlight";
- >
- {
- pass D3_FALLBACK_PASS_02_PS11
- {
- VertexShader = compile vs_1_1 VS_Fallback_ForPS11HW();
- PixelShader = compile ps_1_1 PS_Fallback_ForPS11HW();
-
- AlphaBlendEnable = false;
- ZEnable = true;
- ZFunc = LESSEQUAL;
- ZWriteEnable = true;
-
- CullMode = CCW;
- }
- }
-
- technique D3_FALLBACK_TECHNIQUE_PS11_MORELIGHT
- <
- string Rs_PSVersion = "PS_1_1";
- string Rs_TechniqueMode = "morelights";
- >
- {
- pass D3_FALLBACK_PASS_02_PS11
- {
- VertexShader = compile vs_1_1 VS_Fallback_ForPS11HW();
- PixelShader = compile ps_1_1 PS_Fallback_ForPS11HW();
-
- AlphaBlendEnable = true;
-
- SrcBlend = ONE;
- DestBlend = ONE;
-
- ZEnable = true;
- ZFunc = EQUAL;
- ZWriteEnable = false;
-
- CullMode = CCW;
- }
- }
-
- //------------------------------
- // This is a fallback code for old DX7 hardware with the DOT3 capabilities
- // Specular is computed per vertex, diffuse is computed per pixel
- //------------------------------
- //TODO: Here comes the DOT3 technique
-
- //------------------------------
- // This is a fallback code for old DX7 hardware even without DOT3 capabilities
- // Entire lighting is computed per vertex and diffuse texture is used.
- //------------------------------
- struct VS_OUTPUT_SIMPLE_DX7 {
- float4 vClipPos: POSITION; //Clipping space position
- float2 tcCoord0: TEXCOORD0; //Texture coordinates
- float4 cColor0 : COLOR0; //diffuse map mod
- float4 cColor1 : COLOR1; //specular color + diffuse color mod
- };
-
- VS_OUTPUT_SIMPLE_DX7 VS_Fallback_Simple_DX7(in D3_VERTEXINPUT input) {
- VS_OUTPUT_SIMPLE_DX7 output;
-
- //Following code outputs position and texture coordinates
- //------------------------------
- output.vClipPos = mul(input.D3_pInputPosition, D3_mObjectToClip); //vertex clip position
- output.tcCoord0 = RsD3DComputeTexCoords(input.D3_vInputTexCoords1); //Texture coordinates for color texture
- float4 pVertexWorld = mul(input.D3_pInputPosition, D3_mObjectToWorld); //Transform vertex into world position
-
- //Compute light and eye vectors
- //------------------------------
- float3 vToLight = lerp(ps11fal_LightPos.xyz - pVertexWorld.xyz, -ps11fal_LightDir, ps11fal_LightToggle);
- float fRealDistToLight = length(vToLight);
- vToLight = normalize(vToLight);
-
- float3 vToEye = normalize(D3_pEye - pVertexWorld);
-
- //Compute final light color with respect to the attenuation
- //------------------------------
- float fDistToLight = max(0, fRealDistToLight - ps11fal_LightAttenStart);
- float fAttenuation = ps11fal_LightAtten.x * fDistToLight * fDistToLight + ps11fal_LightAtten.y * fDistToLight + ps11fal_LightAtten.z;
- fAttenuation = saturate(1 / fAttenuation);
- float4 output_cLightColor = ps11fal_LightColor * fAttenuation;
-
- //Compute final per vertex color using light/specular/diffuse
- //------------------------------
- float3 vNormal = normalize(mul(input.D3_vInputNormal, D3_mObjectToWorldN));
- float3 vRefVec = dot(vToLight, vNormal) * 2 * vNormal - vToLight;
- float fEyeDotRef = max(0, dot(vRefVec, vToEye));
-
- float4 output_cSpecularCol = ps11fal_SpecularColor * pow(fEyeDotRef, RsD3DComputeShininess());
- float4 output_cVertexColor = input.D3_cInputColor * ps11fal_VertexColorMod + ps11fal_DiffuseColor;
-
- float fDiffuseDot = saturate(dot(vNormal, vToLight));
- output.cColor0.xyz = saturate(output_cLightColor * ps11fal_DiffuseMapMod * fDiffuseDot);
- output.cColor0.a = 1.0f;
-
- output.cColor1.xyz = saturate(output_cLightColor * (output_cSpecularCol + (output_cVertexColor * fDiffuseDot)));
- output.cColor1.a = 1.0f;
- return output;
- }
-
- //The Dx7 without explicit texture cascade
- technique D3_FALLBACK_TECHNIQUE_DX7_NOMADD
- <
- string Rs_PSVersion = "PS_NONE";
- string Rs_TechniqueMode = "firstlight";
- >
- {
- pass D3_FALLBACK_PASS_02
- {
- VertexShader = compile vs_1_1 VS_Fallback_Simple_DX7();
- PixelShader = NULL;
-
- AlphaBlendEnable = false;
- ZEnable = true;
- ZFunc = LESSEQUAL;
- ZWriteEnable = true;
-
- // Set texture filtering.
- MinFilter[0] = Linear;
- MagFilter[0] = Linear;
- MipFilter[0] = Point;
-
- // Set texture into stage 0.
- Texture[0] = (ps11fal_DiffuseMap);
-
- SpecularEnable = true;
- ColorVertex = true;
- Lighting = false;
- ShadeMode = GOURAUD;
-
- CullMode = CCW;
- }
- }
-
- technique D3_FALLBACK_TECHNIQUE_DX7_NOMADD_MORELIGHTS
- <
- string Rs_PSVersion = "PS_NONE";
- string Rs_TechniqueMode = "morelights";
- >
- {
- pass D3_FALLBACK_PASS_02
- {
- VertexShader = compile vs_1_1 VS_Fallback_Simple_DX7();
- PixelShader = NULL;
-
- AlphaBlendEnable = true;
-
- SrcBlend = ONE;
- DestBlend = ONE;
-
- ZEnable = true;
- ZFunc = EQUAL;
- ZWriteEnable = false;
-
- // Set texture filtering.
- MinFilter[0] = Linear;
- MagFilter[0] = Linear;
- MipFilter[0] = Point;
-
- // Set texture into stage 0.
- Texture[0] = (ps11fal_DiffuseMap);
-
- SpecularEnable = true;
- ColorVertex = true;
- Lighting = false;
- ShadeMode = GOURAUD;
-
- CullMode = CCW;
- }
- }
-
- struct VS_OUTPUT_SIMPLE_DX7_NOTEX {
- float4 vClipPos: POSITION; //Clipping space position
- float4 cColor0 : COLOR0; //diffuse map mod
- };
-
- VS_OUTPUT_SIMPLE_DX7_NOTEX VS_Fallback_Simple_DX7NOTEX(in D3_VERTEXINPUT input) {
- VS_OUTPUT_SIMPLE_DX7_NOTEX output;
-
- //Following code outputs position and texture coordinates
- //------------------------------
- output.vClipPos = mul(input.D3_pInputPosition, D3_mObjectToClip); //vertex clip position
- float4 pVertexWorld = mul(input.D3_pInputPosition, D3_mObjectToWorld); //Transform vertex into world position
-
- //Compute light and eye vectors
- //------------------------------
- float3 vToLight = lerp(ps11fal_LightPos.xyz - pVertexWorld.xyz, -ps11fal_LightDir, ps11fal_LightToggle);
- float fRealDistToLight = length(vToLight);
- vToLight = normalize(vToLight);
-
- float3 vToEye = normalize(D3_pEye - pVertexWorld);
-
- //Compute final light color with respect to the attenuation
- //------------------------------
- float fDistToLight = max(0, fRealDistToLight - ps11fal_LightAttenStart);
- float fAttenuation = ps11fal_LightAtten.x * fDistToLight * fDistToLight + ps11fal_LightAtten.y * fDistToLight + ps11fal_LightAtten.z;
- fAttenuation = saturate(1 / fAttenuation);
- float4 output_cLightColor = ps11fal_LightColor * fAttenuation;
-
- //Compute final per vertex color using light/specular/diffuse
- //------------------------------
- float3 vNormal = normalize(mul(input.D3_vInputNormal, D3_mObjectToWorldN));
- float3 vRefVec = dot(vToLight, vNormal) * 2 * vNormal - vToLight;
- float fEyeDotRef = max(0, dot(vRefVec, vToEye));
-
- float4 output_cSpecularCol = ps11fal_SpecularColor * pow(fEyeDotRef, RsD3DComputeShininess());
- float4 output_cVertexColor = input.D3_cInputColor * ps11fal_VertexColorMod + ps11fal_DiffuseColor;
-
- float fDiffuseDot = saturate(dot(vNormal, vToLight));
- float4 vOutFinal0 = saturate(output_cLightColor * ps11fal_DiffuseMapMod * fDiffuseDot);
-
- float4 vOutFinal1 = saturate(output_cLightColor * (output_cSpecularCol + (output_cVertexColor * fDiffuseDot)));
- output.cColor0.xyz = vOutFinal0 + vOutFinal1;
- output.cColor0.a = 1.0f;
- return output;
- }
-
- //DX7 technique for HW without textures - all per vertex
- technique D3_FALLBACK_TECHNIQUE_DX7
- <
- string Rs_PSVersion = "PS_NONE";
- string Rs_TechniqueMode = "firstlight";
- >
- {
- pass D3_FALLBACK_PASS_02
- {
- VertexShader = compile vs_1_1 VS_Fallback_Simple_DX7NOTEX();
- PixelShader = NULL;
-
- AlphaBlendEnable = false;
-
- ZEnable = true;
- ZFunc = LESSEQUAL;
- ZWriteEnable = true;
-
- Lighting = false;
- ShadeMode = GOURAUD;
-
- CullMode = CCW;
- }
- }
-
- technique D3_FALLBACK_TECHNIQUE_DX7_MORELIGHTS
- <
- string Rs_PSVersion = "PS_NONE";
- string Rs_TechniqueMode = "morelights";
- >
- {
- pass D3_FALLBACK_PASS_02
- {
- VertexShader = compile vs_1_1 VS_Fallback_Simple_DX7NOTEX();
- PixelShader = NULL;
-
- AlphaBlendEnable = true;
-
- SrcBlend = ONE;
- DestBlend = ONE;
-
- ZEnable = true;
- ZFunc = EQUAL;
- ZWriteEnable = false;
-
- Lighting = false;
- ShadeMode = GOURAUD;
-
- CullMode = CCW;
- }
- }
-
- //------------------------------
- // This is a fallback code for absolutely weird hardware
- // No texture, just vertex colors
- //------------------------------
- struct VS_OUTPUT_SIMPLE {
- float4 vClipPos: POSITION; //Clipping space position
- float4 cColor : COLOR; //vertex color
- };
-
- VS_OUTPUT_SIMPLE VS_Fallback_Simple(float4 vPosition : POSITION, float3 vNormal : NORMAL, float4 cColor : COLOR) {
- VS_OUTPUT_SIMPLE output;
-
- output.vClipPos = mul(vPosition, D3_mObjectToClip); //vertex clip position
- float4 pVertexWorld = mul(vPosition, D3_mObjectToWorld); //Transform vertex into world position
-
- float3 vLight = normalize(D3_pEye - pVertexWorld);
- vNormal = normalize(mul(vNormal, D3_mObjectToWorldN));
-
- float Diffuse = saturate(dot(vNormal, vLight));
- output.cColor = cColor * Diffuse;
- return output;
- }
-
- technique D3_FALLBACK_TECHNIQUE
- <
- string Rs_PSVersion = "PS_NONE";
- string Rs_TechniqueMode = "firstlight";
- >
- {
- pass D3_FALLBACK_PASS_02
- {
- VertexShader = compile vs_1_1 VS_Fallback_Simple();
- PixelShader = NULL;
-
- AlphaBlendEnable = false;
-
- ZEnable = true;
- ZFunc = LESSEQUAL;
- ZWriteEnable = true;
-
- CullMode = CCW;
- }
- }
-
- technique D3_FALLBACK_TECHNIQUE_MORELIGHT
- <
- string Rs_PSVersion = "PS_NONE";
- string Rs_TechniqueMode = "morelights";
- >
- {
- pass D3_FALLBACK_PASS_02
- {
- VertexShader = compile vs_1_1 VS_Fallback_Simple();
- PixelShader = NULL;
-
- AlphaBlendEnable = false;
-
- ZEnable = true;
- ZFunc = NEVER;
- ZWriteEnable = false;
-
- CullMode = CCW;
- }
- }
-